<!-- +----------------------------------------------------------------------
| 麦沃德科技赋能开发者，助力中小企业发展 
+----------------------------------------------------------------------
| Copyright (c) 2017～2024  www.wdadmin.cn    All rights reserved.
+----------------------------------------------------------------------
| 沃德代驾系统并不是自由软件，不加密，并不代表开源，未经许可不可自由转售和商用
+----------------------------------------------------------------------
| Author: MY WORLD Team <bd@maiwd.cn>   www.wdadmin.cn
+----------------------------------------------------------------------
| 帮助中心-详情 开发者: 麦沃德科技-半夏
+---------------------------------------------------------------------- -->

<template>
	<view class="container" v-if="loadEnd">
		<view class="container-title">{{helpInfo.title}}</view>
		<view class="container-content">
			<mp-html :content="helpInfo.reply"></mp-html>
		</view>
	</view>
</template>

<script>
	import { mapState } from "vuex"
	export default {
		data() {
			return {
				// 加载完成
				loadEnd: false,
				// 帮助id
				helpId: null,
				// 帮助详情
				helpInfo: {},
			}
		},
		computed: {
			...mapState({
				shareImage: state => state.shareImage,
			})
		},
		onLoad(option) {
			uni.showLoading({
				title: "加载中"
			})
			this.helpId = option.id
			this.getHelpInfo(() => {
				this.loadEnd = true
				uni.hideLoading()
			})
		},
		onShareAppMessage() {
			return {
				title: this.helpInfo.title,
				imageUrl: this.shareImage,
			}
		},
		onShareTimeline() {
			return {
				title: this.helpInfo.title,
				imageUrl: this.shareImage,
			}
		},
		methods: {
			// 获取问题详情
			getHelpInfo(fn) {
				this.$util.request("main.help.details", {
					id: this.helpId
				}).then(res => {
					if (fn) fn()
					if (res.code == 1) {
						this.helpInfo = res.data
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none'
						})
					}
				}).catch(error => {
					if (fn) fn()
					console.error('获取问题详情 ', error)
				})
			},
		},
	}
</script>

<style lang="scss">
	page {
		background: #ffffff;
	}

	.container {
		padding: 32rpx;

		.container-title {
			color: #242629;
			font-size: 32rpx;
			font-weight: 600;
			line-height: 44rpx;
		}

		.container-content {
			margin-top: 32rpx;
			color: #242629;
			font-size: 28rpx;
			line-height: 40rpx;
		}
	}
</style>